home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / kbdready.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-13  |  678 b   |  38 lines

  1. /*
  2. ** kbdready.c
  3. **
  4. ** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
  5. ** Redistributed by permission.
  6. */
  7.  
  8. #include "pictor.h"
  9.  
  10. extern int _PL_pushedkey;
  11.  
  12. /*
  13. ** Returns the next available keystroke without removing it from
  14. ** the keyboard buffer. Returns 0 if no keystrokes available.
  15. */
  16. int kbdready(void)
  17. {
  18.     int key = 0;
  19.  
  20.     if(_PL_pushedkey) {
  21.         key = _PL_pushedkey;
  22.     }
  23.     else {
  24.         /* use in-line assembler to correctly */
  25.         /* detect an empty keyboard buffer */
  26.         _asm    mov   ah,01h
  27.         _asm    int   16h
  28.         _asm    jz    end_kbdready
  29.         _asm    cmp   ax,1
  30.         _asm    adc   ax,0
  31.         _asm    mov   key,ax
  32.     }
  33.     end_kbdready:
  34.  
  35.     return(key);
  36.  
  37. } /* kbdready */
  38.